<template>
  <div class="common-head">
    <div class="head-fl">
      <i @click="toggleNavState" :class="['icon', $store.state.base.navCollapse? 'el-icon-s-unfold': 'el-icon-s-fold']"></i>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/dashBoard' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item v-if="$route.path !== '/dashBoard'">{{$route.name}}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="head-fr">
      <el-dropdown>
        <div class="user-info">
          <span>{{$store.state.user.userInfo.nickName}}</span>
          <el-avatar :size="40" :src="$store.state.user.userInfo.avatar"/>
        </div>
         <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>个人中心</el-dropdown-item>
          <el-dropdown-item>
            <div  @click="logout">退出登录</div>
          </el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>

<script>
export default {
  methods: {
    toggleNavState () {
      // 点击切换导航的折叠状态
      this.$store.commit('base/TOGGLE_NAV')
    },
    logout () {
      // 退出登录
      this.$store.commit('user/RM_USER_INFO')
      this.$router.go(0)
    }
  }
}
</script>

<style lang="scss" scoped>
.common-head{
  display: flex;
  justify-content: space-between;
  height: 100%;
  .head-fl{
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    i.icon{
      margin-right: 15px;
      font-size: 22px;
      cursor: pointer;
    }
  }
  .head-fr{
    height: 100%;
    .user-info{
      cursor: pointer;
      height: 60px;
      display: flex;
      align-items: center;
      font-size: 14px;
      margin-right: 20px;
      span{
        margin-right: 10px;
      }
    }
  }
}
</style>
